import type { Major } from "@/types/major"
import request from "./request"
import type { DataList, pageForm, RESPONSE } from "@/types/base"

enum API {
  ADD_MAJOR = "/manage/major/add",
  GET_ALL_MAJOR = "/manage/major/all",
  GET_MAJOR = "/manage/major/list",
  UPDATE_MAJOR = "/manage/major/update",
  DEL_MAJOR = "/manage/major/delete",
}

export const reqAddMajor = (data: Major) =>
  request.post<null, RESPONSE<Major>>(API.ADD_MAJOR, data)

export const reqGetAllMajor = () =>
  request.get<null, RESPONSE<Major[]>>(API.GET_ALL_MAJOR)

export const reqGetMajor = (data: pageForm) =>
  request.post<null, RESPONSE<DataList<Major[]>>>(API.GET_MAJOR, data)

export const reqUpdateMajor = (data: Major) =>
  request.post<null, RESPONSE<Major>>(API.UPDATE_MAJOR, data)

export const reqDelMajor = (data: { majorId: string }) =>
  request.post<null, RESPONSE<null>>(API.DEL_MAJOR, data)
